﻿// Study1013.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第十章 STL和泛型 函数对象 普通函数/类定义()重载/STL标准函数对象


#include <iostream>
#include <numeric>
#include <functional>
using namespace std;

class MultClass
{
public:
	int operator ()(int x,int y)
	{
		return x * y;
	}
};
int mult(int x,int y)
{
	return x * y;
}
int main()
{
	int a[] = { 1,2,3,4,5 };
	const int N = sizeof(a) / sizeof(int);
	cout << "The result by multipling all element in a is " << accumulate(a, a + N,1, mult) << endl;//普通函数
	cout << "The result by multipling all element in a is " << accumulate(a, a + N,1, MultClass()) << endl;//类定义()重载
	cout << "The result by multipling all element in a is " << accumulate(a, a + N, 1, multiplies<int>()) << endl;
	//STL标准函数对象
	
	return 0;
}

